home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #15
/
Monster Media Number 15 (Monster Media)(July 1996).ISO
/
os2
/
srefv112.zip
/
SREFPRC1.DOC
< prev
next >
Wrap
Text File
|
1996-05-25
|
17KB
|
374 lines
SRE-FILTER ver 1.11 Documentation: SREFPRC1.RXL procedure library. 5/24/96
SRE-Filter uses "macrospace" to store many of it's procedures, and also
as a cache for user-configurable input files. These procedures are
stored in a "macrospace library file" called SREFPRC1.RXL. When
SRE-FILTER is first run (that is, when GoServe is started, and the first
request arrives), SRE-FILTER will load this library into macrospace.
Procedures stored in macrospace are available to all OS/2 programs, including
routines written by ambitious REXX programmers (say, to be used to respond
server side processing requests). Even more ambitious programmers may want
to modify the source code for these procedures!
The source code for these procedures consists of a number of files with
the extention .SRF; all stored in the SREFPRC1.ZIP file. In addition,
SREFPRC1.ZIP contains MAKELIB.CMD,which is used to create the
SREFPRC1.RXL "macrospace library" from these procedures.
To work with macrospace, you can use MSPACE.CMD (also in SREFPRC1.ZIP).
Enter MSPACE ? for instructions on how to use MSPACE.CMD.
------- ---------- --------- ------------
The following describes most of the procedures contained in SREFPRC1.
If you area serious programmer, you may want to look at the source
code (contained in various .SRF files) for further descriptions.
Note that SREFPRC1.RXL is "loaded" into macrospace by SRE-FILTER, which
uses procedures in REXXLIB.DLL.
------- ---------- --------- ------------
------- ---------- --------- ------------
SREF_OPEN_READ: Open a file for read/write (and wait if it's currently locked)
Usage: open_time=sref_open_read(afile ,seconds_to_try_for , howopen )
afile: file to open
seconds_to_try_for : seconds to try for
howopen: BOTH= open as read/write
WRITE= open as write
NEW = open as write, must not already exist
READ = open as read
Returns:
-2 : Timed out
-1 : File does not exist, or does exist (if howopen=WRITE)
>0 : Seconds it took (minimum value of 0.01) to open
------- ---------- --------- ------------
SREF_GRAB_FILE: Read a file, and return it (and wait if it's currently locked)
Usage: afile_string=sref_grab_file(afile,seconds_to_try_for)
(see descriptions above)
Returns:
If file exists/is accessible, returns the file (complete with all
CRLF's etc.). If file does not exist/ is not accessible, returns a 0.
------- ---------- --------- ------------
SREF_REPLACESTRG: Replace substrings
Usage: newstring=sref_replacestr(haystack,needle,replacement, type , exactmatch)
haystack: The string to search in
needle: The string to search for
replacement: Replace occurences of "needle" with "replacement"
type:
FORWARD: Replace first occurence
BACKWARD: Start from end, replace "last" occurence.
ALL: Replace all occurences
exactmatch: if YES, then cases must match (NO=case is ignored).
Note that the case of the "replacement" is retained, regardless
of the value of exactmatch.
Returns:
The haystack,with the replacements (if no replacements, return the
original value of haystack)
------- ---------- --------- ------------
SREF_MEDIATYPE : Returns mime type of a file
Usage: mimetype=sref_mediatype(filename)
Comment: uses the extension of filename to determine the mime type.
For example, AA.HTM would yielld "text/html".
------- ---------- --------- ------------
SREF_HOST: A "host lookup"
Usage: aresult=sref_host(ipaddress)
IPaddress can be numeric or character (with appropriate periods)
Aresult is a sentence noting the ipaddress and the name associated with it.
------- ---------- --------- ------------
SREF_LOOKUP_COUNT : Augment a SRE-FILTER "counter file"
usage: newcount=sref_lookup_count(ctfile, needle, augment , substring , noadd)
ctfile: Name of the "counter file" to examine
Should have a format like: Aneedle ACountT optional info
needle: The target of the search
augment: YES: augment the count
ADD: augment the count, or if needle can not be found,
add new entry with count=1
substring: EXACT: Exact match only
*: Use wildcard match if no exact match
ABBREV: Use abbreviation match if no exact match
noadd: 1: just return matching filename and message
(do NOT lookup count or augment)
2: save the date along with action and count
Returns a space delimited list containing STATUS COUNT Message-String
If status=0, then some failure, 1 then success,
2 then no match, but we added it (only possible if AUGMENT used)
------- ---------- --------- ------------
SREF_EXTRACT_BLOCK : Extract a "labeled block" from a string.
Usage: ablock=sref_extract_block(haystack , alabel , delim1 , delim2 , delim3)
Extract a block from haystack, defined by a Labeled block,
where the label has the form delim1 label delim2 multi-line_string delim3 xxx
Default values of delim1={, 2=} 3={
Note that labels must have NO embedded spaces.
------- ---------- --------- ------------
SREF_INSERT_BLOCK : Insert a block into a string, at a "labeled" location.
Usage: newhaystack=sref_insert_bloc(haystack,alabel,add_string,after,delim1,delim2)
Insert a add_string into haystack, right after or before aLabel.
where the alabel has the form delim1 label delim2
Insertion is immediately after delim2, or before delim1
(if after=1, then after)
Default values of delim1={, 2=}
Note that labels must have NO embedded spaces.
Returns the added to (or not added to) haystack
------- ---------- --------- ------------
SREF_MAKE_BLOCK : Replaces substrings with other substrings.
Usage: newhaystack=sref_make_block(needle, haystack, delim1 , delim2, check_case)
Replace all occurences of NEEDLE in HAYSTACK with delim1 needle delim2.
If delim1 and delim2 not give, then { AND } are used.
Example: make_block(boys,' there are wild boys out there','<b>',' </b>')
returns 'there are wild <b>boys </b> out there'
(note that spaces are all retained).
IF check_case=1, then cases must match (between needle and haystack)
------- ---------- --------- ------------
SREF_FIX_URL : Creates a proper HTTP URL.
Usage: newurl=sref_fix_url(local_url,servername,serverport)
The newurl will contain the http://, servername and port, and local_url.
------- ---------- --------- ------------
SREF_GET_URL : Retrieves a HTTP URL.
Usage: newurl=sref_fix_url(url,maxchar)
Will do socket calls to "GET" a URL. Will get first MAXCHAR
characters; if MAXCHAR is missing, get first 10million (ie. all)
characters.
Returns 0 if any problem -- also SAYs stuff.
------- ---------- --------- ------------
SREF_DO_VIRTUAL: Convert a url into an absolute file.
Usage: absolute_filename=sref_do_virtual(defdir,url_name,mok,virtual_file)
defdir: Default drive:directory to use
rel_name: A url (of the form /A1/A1/FILE.EXT) to
convert to an absolute file name.
mok: If 1, then look in macrospace for a "cached" version
of virtual_file (see sref_load_mac for details)
virtual_file: File containing virtual directory entries
Returns: File name (with drive/directory) or 0 if virtual directory
information (virtual_file) not found. Note that even if the
virtual_file is not used, failure to find it will cause a 0
to be returned (if it is found, but not used, the defdir is used
to build absolute_filename)
------- ---------- --------- ------------
SREF_WILDCARD : Do a wildcard match (with substitution)
Usage: newstring=sref_wildcard(original, target replacement)
See if target matches original. Target can contain *, which are
used as wildcard characters (as with matching file names in OS/2).
If a match occurs, the replacement is returned, possibly with
"substitution" matches -- i.e.; the part of original "covered by" the
* in the target is placed in the replacement
Example: newstring=sref_wildcard('1234567','12*67 abcde*f',0)
yields: newstring= abcde345f
------- ---------- --------- ------------
SREF_JULDATE : Returns julian date (since 1/1/0000) and fractional time
Usage: juldate=sref_juldate(mode, time_string)
mode: F: Date/time is: yy/mm/dd/hh/mm/ss mode (
as returned by sysfiletree(afile,'stem','FT')
T: Date/time is: yyyymmdd hr : mm : sec
as returned by: adate=date('S')|| ' '||time()
Typical return: 729152.125 ; with the fraction accurate to about 1 minute.
------- ---------- --------- ------------
SREF_LOAD_MAC : Cache "user-configurable input files" into macrospace
Usage: status=sref_load__mac(tempdir,user_File,initfilt_file,repstrgs_File, ,
alias_file,interpret_file,virtual_file,access_file,whichone)
Tempdir: working directory (this creates temporary files)
user_file..Access_file: SRE-FILTER's user-configurable input files.
If whichone=0, load all files
Else, choose one of: REPSTRGS INITFILT USER ALIAS INTERPRET VIRTUAL ACCESS
If whichone=0, then update always.
Otherwise, update (just the whichone) only if macrospace version is older
then the file version.
Note that a creation date/time is stored with the "text".
This assumes that macrospace_input =1 (that storage in macrospace is desired).
Returns 1 if an update occured, otherwise 0.
------- ---------- --------- ------------
SREF_VERSION : Returns string listing the SRE-FILTER version
Usage: filter_name=sref_version()
Sample return: SRE-FILTER Ver 1.1 5 May 1996
(the date is the date this was called)
------- ---------- --------- ------------
SREF_CONJUREF : Create/delete temporary files
Usage: newfiles=conjuref(basedir,basenames,extlist,minfree,mintime)
basedir: directory to clean up (if > 10 files,
remove all files > mintime hours old)
basenames: list of (up to 4-char) file-stems to be used
(a random element will be added)
extlist: list of up to 10 extension to be added to this file-stems
So, if base= ZDOG,ZMOM and EXTLIST is FOO,CAT,001 then this will create
ZDOGxxxx.FOO, ZMOMxxxx.CAT and ZMOMxxxx.001, where xxxx is some 4 digit
random # (guaranteed to cause unique file names to be selected)
(note replication to generate as many names as longest list)
minfree: Try to get this much space free by deleting files
from basedir (in kb)
mintime: But don't delete anything less than this hours old
Return: If newfiles=0, then could not create (say, minfree was violated)
Else, comma delimited list of file names
that can be used as temporary files.
CAUTION: Be careful what you choose as your basedir (you could automatically
delete important stuff if your basedir is not strictly a "temporary files"
directory).
------- ---------- --------- ------------
SREF_CHK_PRIV : Check user file to see if a "logged on" client has a privilege
Usage: gotit=sref_chk_priv(targclass,privset0,user_file)
Target: The privilege to check for.
Privset0: Currently available privilegs (perhaps automatically
granted at logon)
user_file: File containing username, password, and privileges
information.
This first checks the "current" privileges (PRIVSET0). If TARGET is
not found therein, then...
... the client may never have "logged on", and may have an account
. containing additional "privileges".
So, give them an opportunity to "explicitily logon" (and obtain these additional
privileges).
Return:
If privilege exists (in privset0 or from a privilige obtained by explicitily
logging on), RETURN 1.
Otherwise, RETURN 0
Special case: if Targets= 0,
just return the "explicitily logon obtained" privileges
should be called as newpriv=sref_chk_priv(0,0,userfile)
------- ---------- --------- ------------
SREF_MAILIT : Use REXX socket calls to send e-mail
Usage: status=mailit(address_list,messagesmtp_gateway,sender_address)
address_list: A space delimited list of addresses
message: A message string, that may contain CRLFs
(and may be rather long)
smtp_gateway: The IP address of your SMTP server
sender_address: The sender's address (optional)
If sender's address is not given, it will be generated using
GoServe's servername() function.
Examples:
status=mailit("BOB@HIS.NET" , "This is my message ", "MAIL.MY.ORG" )
status= mailit("BOB@HIS.NET JILL@HER.COM " , "This is my message ", ,
"MAIL.MY.ORG", "HARRY@MY.ORG")
Note on recipient addresses:
The message will be sent to each address. Since the addresses are
sent and then the message, this allows for fairly rapid mailing to multiple
individuals.
------- ---------- --------- ------------
SREF_NEW_GMT: Compute a new GMT time, given a date,time,and offset
usage new_gmt_time=sref_new_gmt(frac_day,adate,asec)
Frac_day =fraction of a day to add to adate and asec (default=0)
adate is a date in 'base date' format, default is date when called
(i.e.; date('b')
asec is a second in day, default is time when called (i.e.; time('s')
------- ---------- --------- ------------
SREF_EXPIRE_RESPONSE: Build a response header that does not have an
immediate expiration.
Usage: foo=sref_expire_respons(aoffset,alength,atype,noauto)
aoffset is fraction of day to add to current date/time. This will
be converted to gmt (assuming gmt variables have been set, as described
in goserve.doc). If aoffset<0, then an "expires" header will Not
be written. Default is 0.04
alength is the size of the document being sent. Default is 0
atype is the mime type. Default is text/html
noauto= Y or N: If Y, or if missing, then suppress auto - headers.
This is meant to be used when the default response headers are inappropriate.
For example, if returing a file with server side includes (say, using FILE ERASE
or VAR), GoServe will always give an "immediate" expiration time. This can
aggravate clients with browsers that reload the document when the document
is "backed up" to. By giving a small aoffset (say, 0.02), most of this
can be avoided (assuming that the document being sent to the client
does not need minute-by-minute updating!)
Note that if noauto=N, we HIGHLY recommend using a 'HEADER NOAUTO' statement
somewhere before this call. If you do not have such a line, the GoServe
default headers, and the headers generated here, will be sent. Very confusing!
------- ---------- --------- ------------
------- ---------- --------- ------------
Citations:
SRE-FILTER uses the macrospace manipulation routines
that come with the REXXLIB library. REXXLIB is shareware that can
be found at HOBBES.NMSU.EDU (try the OS2/DEV32/REXX directory) ,or
directly from www.quercus-sys.com/rexxlib.htm.
SREF_MAILIT is a modification of a routine written by Dave Briccetti.
SREF_GET_URL is adapted from MOVEAUD.CMD, that comes with GoServe.